package pdm.yamba.dto;

import android.os.Parcel;
import android.os.Parcelable;

public class User implements Parcelable {
	private String username;
	private String password;
	private boolean isLoggedIn;
	private int messageCount;
	private int subscriptionNumber;
	private int subscribersCount;
	
	
    public static final Parcelable.Creator<User> CREATOR = new Parcelable.Creator<User>() 
	{
        public User createFromParcel(Parcel in) 
        {
            return new User(in);
        }

        public User[] newArray(int size) 
        {
            return new User[size];
        }
    };

	
	public User(String username, String password, boolean isLoggedIn)
	{
		this.username = username;
		this.password = password;
		this.isLoggedIn = isLoggedIn;
	}
	
    private User(Parcel in) {
        readFromParcel(in);
    }
	
	public String getUsername() 
	{
		return username;
	}
	
	public void setUsername(String username) 
	{
		this.username = username;
	}
	
	public String getPassword() 
	{
		return password;
	}
	
	public void setPassword(String password) 
	{
		this.password = password;
	}
	
	public boolean isLoggedIn() 
	{
		return isLoggedIn;
	}
	
	void setLoggedIn(boolean isLoggedIn) 
	{
		this.isLoggedIn = isLoggedIn;
	}

	@Override
	public int describeContents() 
	{
		return 0;
	}
	
	@Override
    public void writeToParcel(Parcel out, int flags) 
	{
        out.writeString(username);
        out.writeString(password);
        out.writeByte((byte) (isLoggedIn ? 1 : 0));
        out.writeInt(getMessageCount());
        out.writeInt(getSubscriptionNumber());
        out.writeInt(getSubscribersCount());
    }

    public void readFromParcel(Parcel in) 
    {
        username = in.readString();
        password = in.readString();
        isLoggedIn = in.readByte() == 1;
        setMessageCount(in.readInt());
        setSubscriptionNumber(in.readInt());
        setSubscribersCount(in.readInt());
    }

    public int getMessageCount() {
		return messageCount;
	}

    public void setMessageCount(int messageCount) {
		this.messageCount = messageCount;
	}

    public int getSubscriptionNumber() {
		return subscriptionNumber;
	}

    public void setSubscriptionNumber(int subscriptionNumber) {
		this.subscriptionNumber = subscriptionNumber;
	}

    public int getSubscribersCount() {
		return subscribersCount;
	}

    public void setSubscribersCount(int subscribersCount) {
		this.subscribersCount = subscribersCount;
	}
}